package cn.livingCloud.dto;

import cn.livingCloud.entity.core.Case;
import cn.livingCloud.entity.core.CaseStatus;
import cn.livingCloud.entity.core.Employee;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 唐旭 on 2016/6/2.
 */
public class CaseBaseDto {
    protected String uuid;
    protected String creatorUuid;
    protected String addressDescription;
    protected String phone;
    protected Float locationX;
    protected Float locationY;
    protected CaseStatus status = CaseStatus.NO_HANDLE;
    protected String ownerId;
    protected String caseCategoryUuid;

    protected MemberDto creatorDto;
    protected List<EmployeeDto> ownerList = new ArrayList<>();
    protected CaseCategoryDto categoryDto;
    protected CaseStatus disableStatus;

    public CaseBaseDto() {
    }

    public CaseBaseDto(Case aCase) {
        this.uuid = aCase.getUuid();
        this.creatorUuid = aCase.getCreatorUuid();
        this.addressDescription = aCase.getAddressDescription();
        this.phone = aCase.getPhone();
        this.locationX = aCase.getLocationX();
        this.locationY = aCase.getLocationY();
        this.status = aCase.getStatus();
        this.ownerId = aCase.getOwnerId();
        this.caseCategoryUuid = aCase.getCaseCategoryUuid();
        this.disableStatus = aCase.getDisableStatus();

        if (StringUtils.isNotEmpty(creatorUuid)) {
            creatorDto = new MemberDto(aCase.getMember());
        }
        if (StringUtils.isNotEmpty(ownerId)) {
            List<Employee> ownerList = aCase.getOwnerList();
            for (Employee employee : ownerList) {
                this.ownerList.add(new EmployeeDto(employee));
            }
        }
        if (StringUtils.isNotEmpty(caseCategoryUuid)) {
            categoryDto = new CaseCategoryDto(aCase.getCaseCategory());
        }
    }

    public String getAddressDescription() {
        return addressDescription;
    }

    public CaseBaseDto setAddressDescription(String addressDescription) {
        this.addressDescription = addressDescription;
        return this;
    }

    public String getCaseCategoryUuid() {
        return caseCategoryUuid;
    }

    public CaseBaseDto setCaseCategoryUuid(String caseCategoryUuid) {
        this.caseCategoryUuid = caseCategoryUuid;
        return this;
    }

    public CaseCategoryDto getCategoryDto() {
        return categoryDto;
    }

    public CaseBaseDto setCategoryDto(CaseCategoryDto categoryDto) {
        this.categoryDto = categoryDto;
        return this;
    }

    public MemberDto getCreatorDto() {
        return creatorDto;
    }

    public CaseBaseDto setCreatorDto(MemberDto creatorDto) {
        this.creatorDto = creatorDto;
        return this;
    }

    public String getCreatorUuid() {
        return creatorUuid;
    }

    public CaseBaseDto setCreatorUuid(String creatorUuid) {
        this.creatorUuid = creatorUuid;
        return this;
    }

    public Float getLocationX() {
        return locationX;
    }

    public CaseBaseDto setLocationX(Float locationX) {
        this.locationX = locationX;
        return this;
    }

    public Float getLocationY() {
        return locationY;
    }

    public CaseBaseDto setLocationY(Float locationY) {
        this.locationY = locationY;
        return this;
    }

    public List<EmployeeDto> getOwnerList() {
        return ownerList;
    }

    public CaseBaseDto setOwnerList(List<EmployeeDto> ownerList) {
        this.ownerList = ownerList;
        return this;
    }

    public String getOwnerId() {
        return ownerId;
    }

    public CaseBaseDto setOwnerId(String ownerId) {
        this.ownerId = ownerId;
        return this;
    }

    public String getPhone() {
        return phone;
    }

    public CaseBaseDto setPhone(String phone) {
        this.phone = phone;
        return this;
    }

    public CaseStatus getStatus() {
        return status;
    }

    public CaseBaseDto setStatus(CaseStatus status) {
        this.status = status;
        return this;
    }

    public String getUuid() {
        return uuid;
    }

    public CaseBaseDto setUuid(String uuid) {
        this.uuid = uuid;
        return this;
    }

    public CaseStatus getDisableStatus() {
        return disableStatus;
    }

    public CaseBaseDto setDisableStatus(CaseStatus disableStatus) {
        this.disableStatus = disableStatus;
        return this;
    }
}
